package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.clazz.CustomCardClass;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: wufeng
 * @date: 2018/8/30 14:08
 * @desrcption: 自定义卡片枚举
 */
public enum CustomCardEnum {

    COMMON_FORM(1, "common_form", "enum.customCard.memo.common_form"),
    MESSAGE(2, "message", "enum.customCard.memo.message"),
    CREATE_PROCESS(3, "create_process", "enum.customCard.memo.create_process"),
    TODO_PROCESS(4, "todo_process", "enum.customCard.memo.todo_process"),
    REPORT_FORM(5, "report_form", "");

    private Integer type;

    private String alias;

    private String memo;

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    CustomCardEnum(Integer type, String alias, String memo){
        this.type = type;
        this.alias = alias;
        this.memo = memo;
    }

    public static String getMemo(Integer type){
        for (CustomCardEnum cardEnum: values()) {
            if (type.equals(cardEnum.getType())){
                return cardEnum.getMemo();
            }
        }
        return null;
    }

    public static List<CustomCardClass> getCardList(){
        List<CustomCardClass> list = new ArrayList<>();
        for (CustomCardEnum cardEnum: values()) {
            CustomCardClass customCardClass = new CustomCardClass();
            customCardClass.setType(cardEnum.getType());
            customCardClass.setAlias(cardEnum.getAlias());
            customCardClass.setMemo(cardEnum.getMemo());
            list.add(customCardClass);
        }
        return list;
    }

}
